
import bpy

import 全局控制.Node.插座.bl_插座基类 as 插件基类

import Core.bl_UI配色 as UI配色

import engine.initLIB.load_dll as engineLib
import ctypes





def f_socketStrUpdate(self, context):
	engineLib.flexCAPI.f_bl_插座传入数据(
		ctypes.c_wchar_p(self.node.id_data.name), 
		ctypes.c_wchar_p(self.node.name), 
		ctypes.c_wchar_p(self.identifier), 
		ctypes.py_object(list(self.default_value)),
		ctypes.c_bool(self.is_output)
	)
	
	if context :
		self.id_data.f_节点数据更新_更新树([self.node])









class C_Socket_文本(插件基类.C_Socket_基类):
	name = '文本'
	bl_label = '文本'
	
	default_value = bpy.props.StringProperty()
	def __init__(self):
		super(C_Socket_文本, self).__init__()
		
	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop(self, 'default_value', text=text)
		else:
			layout.label(text="str:"+text)
	def draw_color(self, context, node):
		return UI配色.g_文本插座颜色

	def f_getData(self):
		if self.is_linked == False :
			return self.default_value
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
		
	def f_setData(self, data):
		self.m_Value = str(data)
		f_socketStrUpdate(self, None)
	def f_update(self):
		f_socketStrUpdate(self, None)


classes = (
	C_Socket_文本,
	
)




def register():
	for c in classes:
		bpy.utils.register_class(c)
	pass	

def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)
	pass
	

